<?php
class template_all extends theme
{

	protected function center()
	{
		$menu_id = request('menu_id', 0);
		$category_id = $this->get('category_id');
		$content_list = $this->get('content_list');
		$category_list = $this->get('category_list');
		?>

<h3 class="title"><?php echo $this->get_title(); ?></h3>
		
<p>
选择分类: 
<select onchange="javascript:window.location.href='./?controller=content&task=all&menu_id=<?php echo $menu_id; ?>&category_id='+this.options[this.selectedIndex].value;">
<?php 

$category_name = array();

echo '<option value="-1"> - 所有文章 - </option>';
foreach($category_list as $category)
{
	echo '<option value="'.$category->id.'"';
	if($category->id == $category_id) echo ' selected';
	echo '>';
	if($category->level) echo str_repeat('&nbsp; ', $category->level);
	echo '- '.$category->name.' -</option>';
	
	$category_name[$category->id] = $category->name;
}
?>
</select>
</p>
		
<ul>
<?php 
if(count($content_list))
{
	foreach($content_list as $content)
	{
		?>
		<li>
		[<a href="<?php echo url('./?controller=content&task=all&category_id='.$content->category_id.'&menu_id='.$menu_id ); ?>"><?php echo $category_name[$content->category_id]; ?></a>] 
		<a href="<?php echo url('./?controller=content&task=detail&id='.$content->id.'&menu_id='.$menu_id ); ?>"><?php echo $content->title; ?></a>
		</li>
		<?php
	}
}
else
{
	echo '<li>没有记录</li>';
}
?>
</ul>

<p><?php $this->pagination(); ?></p>
		<?php
		
	}	

}
?>